#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

void solve(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    deque<int> dp;
    stack<int> st;
    for(int i=n;i>0;i--){
        while(!dp.empty()&&a[i]>=a[dp.back()])dp.pop_back();
        if(dp.empty())st.push(0);
        else st.push(dp.back());
        dp.push_back(i);
    }
    while(!st.empty()){
        cout<<st.top()<<endl;
        st.pop();
    }
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();

    return 0;
}